clear
set more off

local path0="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\"

cd "`path0'Data\PuttermanWeil\"

import excel "matrix version 1p1.xlsx", cellrange(A1) sheet("matrix version 1p1") firstrow clear

rename wbcode countrycode
rename wbname country

compress
save temp, replace

foreach var in afg	alb	dza	ago	arg	arm	aus	aut	aze	bhr	bgd	blr	bel	blz ///
	ben	btn	bol	bih	bwa	bra	bgr	bfa	bdi	khm	cmr	can	cpv	caf	tcd	chl	chn	///
	col	com	zar	cog	cil	cri	civ	hrv	cub	cyp	cze	dnk	dom	tmp	ecu	egy	slv	///
	gnq	eri	est	eth	fji	fin	fra	gab	gmb	geo	deu	gha	grc	gtm	gin	gnb	guy	///
	hti	hnd	hkg	hun	isl	ind	idn	irn	irq	irl	isr	ita	jam	jpn	jor	kaz	ken	///
	prk	kor	kwt	kgz	lao	lva	lbn	lso	lbr	lby	ltu	lux	mkd	mdg	mwi	mys	mli	///
	mlt	mrt	mus	mex	mda	mng	mar	moz	mmr	nam	npl	nld	nzl	nic	ner	nga	niu	///
	nor	omn	pak	pan	png	pry	per	phl	pol	prt	pri	qat	rom	rus	rwa	vct	wsm	///
	stp	sau	sen	yug	sle	sgp	svk	svn	som	zaf	esp	lka	sdn	swz	swe	che	syr	///
	oan	tjk	tza	tha	tgo	ton	tto	tun	tur	tkm	uga	ukr	are	gbr	usa	ury	uzb	///
	ven	vnm	yem	zmb	zwe {
	
	use temp, clear
	keep countrycode country `var'
	gen source_countrycode=strupper("`var'")
	rename `var' sh
	compress
	save temp_`var', replace
	 
}


use temp_afg, clear


foreach var in alb	dza	ago	arg	arm	aus	aut	aze	bhr	bgd	blr	bel	blz ///
	ben	btn	bol	bih	bwa	bra	bgr	bfa	bdi	khm	cmr	can	cpv	caf	tcd	chl	chn	///
	col	com	zar	cog	cil	cri	civ	hrv	cub	cyp	cze	dnk	dom	tmp	ecu	egy	slv	///
	gnq	eri	est	eth	fji	fin	fra	gab	gmb	geo	deu	gha	grc	gtm	gin	gnb	guy	///
	hti	hnd	hkg	hun	isl	ind	idn	irn	irq	irl	isr	ita	jam	jpn	jor	kaz	ken	///
	prk	kor	kwt	kgz	lao	lva	lbn	lso	lbr	lby	ltu	lux	mkd	mdg	mwi	mys	mli	///
	mlt	mrt	mus	mex	mda	mng	mar	moz	mmr	nam	npl	nld	nzl	nic	ner	nga	niu	///
	nor	omn	pak	pan	png	pry	per	phl	pol	prt	pri	qat	rom	rus	rwa	vct	wsm	///
	stp	sau	sen	yug	sle	sgp	svk	svn	som	zaf	esp	lka	sdn	swz	swe	che	syr	///
	oan	tjk	tza	tha	tgo	ton	tto	tun	tur	tkm	uga	ukr	are	gbr	usa	ury	uzb	///
	ven	vnm	yem	zmb	zwe {
	
	append using temp_`var'
	 
}



keep if countrycode==source_countrycode

label var sh "Putterman-Weil: share of indigineous people in current population"

drop source_countrycode

foreach var in afg	alb	dza	ago	arg	arm	aus	aut	aze	bhr	bgd	blr	bel	blz ///
	ben	btn	bol	bih	bwa	bra	bgr	bfa	bdi	khm	cmr	can	cpv	caf	tcd	chl	chn	///
	col	com	zar	cog	cil	cri	civ	hrv	cub	cyp	cze	dnk	dom	tmp	ecu	egy	slv	///
	gnq	eri	est	eth	fji	fin	fra	gab	gmb	geo	deu	gha	grc	gtm	gin	gnb	guy	///
	hti	hnd	hkg	hun	isl	ind	idn	irn	irq	irl	isr	ita	jam	jpn	jor	kaz	ken	///
	prk	kor	kwt	kgz	lao	lva	lbn	lso	lbr	lby	ltu	lux	mkd	mdg	mwi	mys	mli	///
	mlt	mrt	mus	mex	mda	mng	mar	moz	mmr	nam	npl	nld	nzl	nic	ner	nga	niu	///
	nor	omn	pak	pan	png	pry	per	phl	pol	prt	pri	qat	rom	rus	rwa	vct	wsm	///
	stp	sau	sen	yug	sle	sgp	svk	svn	som	zaf	esp	lka	sdn	swz	swe	che	syr	///
	oan	tjk	tza	tha	tgo	ton	tto	tun	tur	tkm	uga	ukr	are	gbr	usa	ury	uzb	///
	ven	vnm	yem	zmb	zwe {
	
	erase temp_`var'.dta
	 
}


rename sh share_puttermanweil

erase temp.dta
cd "`path0'workfiles"
compress

replace countrycode="GER" if countrycode=="DEU"
replace countrycode="NIC" if countrycode=="NIU"
replace countrycode="TWN" if countrycode=="OAN"
replace countrycode="SCG" if countrycode=="YUG"

save PuttermanWeil, replace




